package org.holdren.jpahibernate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name = "usr")
@NamedQuery(name="User.findAll", query="SELECT usr FROM User usr ")
// @Table is optional, but 'user' is a keyword in many SQL variants
public class User
{ 
	@Id
	// @Id indicates that this it a unique primary key
	@GeneratedValue
	// @GeneratedValue indicates that value is automatically generated by the
	// server
	private Long id;

	@Column(length = 32, unique = true)
	// the optional @Column allows us makes sure that the name is limited to a
	// suitable size and is unique
	private String name;

	// note that no setter for ID is provided, Hibernate will generate the ID
	// for us

	public long getId()
	{
		return id;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getName()
	{
		return name;
	}
}
